package lastStoneWeight;


import java.util.Comparator;
import java.util.PriorityQueue;

public class Solution {
    public int lastStoneWeight(int[] stones) {
        // 优先级队列
        PriorityQueue<Integer> queue = new PriorityQueue<>(stones.length, Comparator.reverseOrder());
        for (int v: stones) {
            queue.add(v);
        }
        while (queue.size()>1){
            queue.add(queue.poll()-queue.poll());
        }
        return queue.poll();
    }
}
